<%@ page import="deepbitview.Sample" %>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <meta name="layout" content="main"/>
    <g:set var="entityName" value="${message(code: 'sample.label', default: 'Sample')}"/>
    <title><g:message code="default.edit.label" args="[entityName]"/></title>
</head>

<body>
<div class="nav">
    <span class="menuButton"><a class="home" href="${createLink(uri: '/')}"><g:message code="default.home.label"/></a>
    </span>
    <span class="menuButton"><g:link class="list" action="list"><g:message code="default.list.label"
                                                                           args="[entityName]"/></g:link></span>
    <span class="menuButton"><g:link class="create" action="create"><g:message code="default.new.label"
                                                                               args="[entityName]"/></g:link></span>
</div>

<div class="body">
    <h1><g:message code="default.edit.label" args="[entityName]"/></h1>
    <g:if test="${flash.message}">
        <div class="message">${flash.message}</div>
    </g:if>
    <g:hasErrors bean="${sampleInstance}">
        <div class="errors">
            <g:renderErrors bean="${sampleInstance}" as="list"/>
        </div>
    </g:hasErrors>
    <g:form method="post">
        <g:hiddenField name="id" value="${sampleInstance?.id}"/>
        <g:hiddenField name="version" value="${sampleInstance?.version}"/>
        <div class="dialog">
            <table>
                <tbody>

                <tr class="prop">
                    <td valign="top" class="name">
                        <label for="difficulty"><g:message code="sample.difficulty.label" default="Difficulty"/></label>
                    </td>
                    <td valign="top" class="value ${hasErrors(bean: sampleInstance, field: 'difficulty', 'errors')}">
                        <g:textField name="difficulty"
                                     value="${fieldValue(bean: sampleInstance, field: 'difficulty')}"/>
                    </td>
                </tr>

                <tr class="prop">
                    <td valign="top" class="name">
                        <label for="exchangeRateUSD"><g:message code="sample.exchangeRateUSD.label"
                                                                default="Exchange Rate USD"/></label>
                    </td>
                    <td valign="top"
                        class="value ${hasErrors(bean: sampleInstance, field: 'exchangeRateUSD', 'errors')}">
                        <g:textField name="exchangeRateUSD"
                                     value="${fieldValue(bean: sampleInstance, field: 'exchangeRateUSD')}"/>
                    </td>
                </tr>

                <tr class="prop">
                    <td valign="top" class="name">
                        <label for="globalBitCoinAmount"><g:message code="sample.globalBitCoinAmount.label"
                                                                    default="Global Bit Coin Amount"/></label>
                    </td>
                    <td valign="top"
                        class="value ${hasErrors(bean: sampleInstance, field: 'globalBitCoinAmount', 'errors')}">
                        <g:textField name="globalBitCoinAmount"
                                     value="${fieldValue(bean: sampleInstance, field: 'globalBitCoinAmount')}"/>
                    </td>
                </tr>

                <tr class="prop">
                    <td valign="top" class="name">
                        <label for="globalNetworkSpeed"><g:message code="sample.globalNetworkSpeed.label"
                                                                   default="Global Network Speed"/></label>
                    </td>
                    <td valign="top"
                        class="value ${hasErrors(bean: sampleInstance, field: 'globalNetworkSpeed', 'errors')}">
                        <g:textField name="globalNetworkSpeed"
                                     value="${fieldValue(bean: sampleInstance, field: 'globalNetworkSpeed')}"/>
                    </td>
                </tr>

                <tr class="prop">
                    <td valign="top" class="name">
                        <label for="globalyKnownBlocks"><g:message code="sample.globalyKnownBlocks.label"
                                                                   default="Globaly Known Blocks"/></label>
                    </td>
                    <td valign="top"
                        class="value ${hasErrors(bean: sampleInstance, field: 'globalyKnownBlocks', 'errors')}">
                        <g:textField name="globalyKnownBlocks"
                                     value="${fieldValue(bean: sampleInstance, field: 'globalyKnownBlocks')}"/>
                    </td>
                </tr>

                <tr class="prop">
                    <td valign="top" class="name">
                        <label for="hashRate"><g:message code="sample.hashRate.label" default="Hash Rate"/></label>
                    </td>
                    <td valign="top" class="value ${hasErrors(bean: sampleInstance, field: 'hashRate', 'errors')}">
                        <g:textField name="hashRate" value="${fieldValue(bean: sampleInstance, field: 'hashRate')}"/>
                    </td>
                </tr>

                <tr class="prop">
                    <td valign="top" class="name">
                        <label for="nextDifficultyEstimate"><g:message code="sample.nextDifficultyEstimate.label"
                                                                       default="Next Difficulty Estimate"/></label>
                    </td>
                    <td valign="top"
                        class="value ${hasErrors(bean: sampleInstance, field: 'nextDifficultyEstimate', 'errors')}">
                        <g:textField name="nextDifficultyEstimate"
                                     value="${fieldValue(bean: sampleInstance, field: 'nextDifficultyEstimate')}"/>
                    </td>
                </tr>

                <tr class="prop">
                    <td valign="top" class="name">
                        <label for="reward"><g:message code="sample.reward.label" default="Reward"/></label>
                    </td>
                    <td valign="top" class="value ${hasErrors(bean: sampleInstance, field: 'reward', 'errors')}">
                        <g:textField name="reward" value="${fieldValue(bean: sampleInstance, field: 'reward')}"/>
                    </td>
                </tr>

                <tr class="prop">
                    <td valign="top" class="name">
                        <label for="sampleTime"><g:message code="sample.sampleTime.label"
                                                           default="Sample Time"/></label>
                    </td>
                    <td valign="top" class="value ${hasErrors(bean: sampleInstance, field: 'sampleTime', 'errors')}">
                        <g:datePicker name="sampleTime" precision="day" value="${sampleInstance?.sampleTime}"/>
                    </td>
                </tr>

                <tr class="prop">
                    <td valign="top" class="name">
                        <label for="workerInstances"><g:message code="sample.workerInstances.label"
                                                                default="Worker Instances"/></label>
                    </td>
                    <td valign="top"
                        class="value ${hasErrors(bean: sampleInstance, field: 'workerInstances', 'errors')}">

                        <ul>
                            <g:each in="${sampleInstance?.workerInstances?}" var="w">
                                <li><g:link controller="workerInstance" action="show"
                                            id="${w.id}">${w?.encodeAsHTML()}</g:link></li>
                            </g:each>
                        </ul>
                        <g:link controller="workerInstance" action="create"
                                params="['sample.id': sampleInstance?.id]">${message(code: 'default.add.label', args: [message(code: 'workerInstance.label', default: 'WorkerInstance')])}</g:link>

                    </td>
                </tr>

                </tbody>
            </table>
        </div>

        <div class="buttons">
            <span class="button"><g:actionSubmit class="save" action="update"
                                                 value="${message(code: 'default.button.update.label', default: 'Update')}"/></span>
            <span class="button"><g:actionSubmit class="delete" action="delete"
                                                 value="${message(code: 'default.button.delete.label', default: 'Delete')}"
                                                 onclick="return confirm('${message(code: 'default.button.delete.confirm.message', default: 'Are you sure?')}');"/></span>
        </div>
    </g:form>
</div>
</body>
</html>
